home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1990: Discy Business / Discy Business.2mg / DEV.CD / TOOLS / SAMPLES / HP / HP.PAS / PRINT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-08-14  |  4.0 KB  |  138 lines  |  [B0] Apple IIgs Source Code (0x001E)

  1. UNIT Print;
  2.  
  3. {+----------------------------------------------------------------------------+
  4.  |                                                                            |
  5.  |         HodgePodge:  An example Apple IIGS Desktop application             |
  6.  |                                                                            |
  7.  |    Written in 65816 assembler and APW C by the Apple IIGS Tools Team       |
  8.  |              Translated to TML Pascal by TML Systems, Inc.                 |
  9.  |  Modified by Ben Koning for "Programmer's Introduction to the Apple IIGS"  |
  10.  |                                                                            |
  11.  |             Copyright (c) 1986-87 by Apple Computer, Inc.                  |
  12.  |                Copyright (c) 1987 by TML Systems, Inc.                     |
  13.  |                                                                            |
  14.  |                     --------------------------------                       |
  15.  |                                                                            |
  16.  |       Pascal UNIT "PRINT.PAS" : Window content printing routines           |
  17.  |                                                                            |
  18.  +----------------------------------------------------------------------------+}
  19.  
  20.  
  21.  
  22. INTERFACE
  23.  
  24. USES
  25.        HPIntfData,         {HodgePodge Apple IIGS Toolbox Interface Units}
  26.        HPIntfProc,
  27.        HPIntfPdos,
  28.  
  29.        Globals,            {HodgePodge Code Units}
  30.        Dialog,
  31.        Font,
  32.        Paint;
  33.  
  34.  
  35.  
  36. procedure DoChooserItem;   {Show standard chooser dialog to select options}
  37. procedure DoSetupItem;     {Show standard page setup dialog to sel options}
  38. procedure DoPrintItem;     {Print contents of current window to printer   }
  39. procedure SetUpDefault;    {Create and initialize THPrint record          }
  40.  
  41.  
  42.  
  43.  
  44.  
  45. IMPLEMENTATION
  46.  
  47.  
  48.  
  49. VAR  PrintHndl:     PrRecHndl;  {Private print record handle for Print Manager}
  50.  
  51.  
  52.  
  53. procedure DrawTopWindow (theWindow: GrafPortPtr);
  54.  
  55.    {This private procedure determines what type of window theWindow is and
  56.     calls the appropriate procedure to draw its contents to the current port
  57.     which is now the printer port created in DoPrintItem.}
  58.  
  59.    var myDataHandle: WindDataH;
  60.  
  61.    begin   {of DrawTopWindow}
  62.        myDataHandle := WindDataH (GetWRefCon (theWindow));
  63.        with myDataHandle^^ do
  64.            if Flag = 0 then
  65.                PaintIt (pict)
  66.            else
  67.                ShowFont (theFont,isMono);
  68.    end;    {of DrawTopWindow}
  69.  
  70.  
  71.  
  72. procedure DoChooserItem;
  73.  
  74.    {Display the Chooser Dialog for the user to select which printer and
  75.     printer connection to use.}
  76.  
  77.    var dummy: boolean;
  78.  
  79.    begin   {of DoChooserItem}
  80.        dummy := PrChooser;
  81.    end;    {of DoChooserItem}
  82.  
  83.  
  84.  
  85. procedure DoPrintItem;
  86.  
  87.    {Print the contents of the front window to the selected printer.}
  88.  
  89.    var  PrPort    : GrafPortPtr;
  90.         theWindow : GrafPortPtr;
  91.  
  92.    begin   {of DoPrintItem}
  93.        theWindow := FrontWindow;
  94.        if theWindow <> nil then
  95.            if PrJobDialog (PrintHndl) then begin
  96.                WaitCursor;
  97.                PrPort := PrOpenDoc (PrintHndl,nil);
  98.                PrOpenPage          (PrPort,nil);
  99.                DrawTopWindow       (theWindow);
  100.                PrClosePage         (PrPort);
  101.                PrCloseDoc          (PrPort);
  102.                PrPicFile           (PrintHndl,nil,nil);
  103.                InitCursor;
  104.            end;
  105.    end;    {of DoPrintItem}
  106.  
  107.  
  108.  
  109. procedure DoSetupItem;
  110.  
  111.    {Display the Page Setup dialog for the user to choose the print mode,
  112.     number of pages, etc. to print.}
  113.  
  114.    var dummy: boolean;
  115.  
  116.    begin   {of DoSetupItem}
  117.        dummy := PrStlDialog (PrintHndl);
  118.    end;    {of DoSetupItem}
  119.  
  120.  
  121.  
  122. procedure SetUpDefault;
  123.  
  124.    {Create and initialize a THPrint record which is required for all
  125.     printing operations.}
  126.  
  127.    begin   {of SetUpDefault}
  128.        PrintHndl := PrRecHndl (NewHandle (140,
  129.                                myMemoryID,
  130.                                attrNoCross + attrLocked,
  131.                                Ptr (0)));
  132.        PrDefault (PrintHndl);
  133.    end;    {of SetUpDefault}
  134.  
  135.  
  136.  
  137. END.
  138.